﻿// Copyright 2010 Maxime Serrano <lastchronicler@gmail.com>
// Copyright 2009, 2010 Matvei Stefarov <me@matvei.org>
using System;

namespace ForgeCraft
{
    public class CmdTimelock : Command
    {
        public override string name { get { return "timelock"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "op"; } }
        public override bool consoleUsable { get { return false; } }
        public override Permission defaultRank { get { return Permission.Guest; } }
        public CmdTimelock() { }

        public override void Use(Player p, string message)
        {
            if (Config.GetBool(ConfigKey.AllowTime))
            {
                Config.SetValue(ConfigKey.AllowTime, false);
                Server.SendToAll(p.info.group.color + p.nick + Color.Sys + " has locked time. Time will no longer progress.");
            }
            else
            {
                Config.SetValue(ConfigKey.AllowTime, true);
                Server.SendToAll(p.info.group.color + p.nick + Color.Sys + " has unlocked time. Time will now progress.");
            }
            Config.Save();
        }
        public override void Help(Player p)
        {
            p.Message(Color.Aqua + "/timelock " + Color.Help + "- Toggles time lock. If locked, time will not progress on the server.");
        }
    }
}